package com.summer.service.impl;

import com.github.pagehelper.PageInfo;
import com.summer.entity.PlateformChannel;
import com.summer.mapper.PlateformChannelMapper;
import com.summer.service.IPlateformChannelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 渠道service
 */
@Slf4j
@Service
public class PlateformChannelService implements IPlateformChannelService{

    @Resource
    private PlateformChannelMapper plateformChannelMapper;

    /**
     * 渠道列表
     * @param params
     * @return
     */
    @Override
    public PageInfo<PlateformChannel> query(Map<String, Object> params) {
        List<PlateformChannel> result = plateformChannelMapper.findParams(params);
        return new PageInfo<>(result);
    }

    /**
     * 修改渠道状态
     * @param plateformChannel
     */
    @Override
    @Transactional
    public void updateByStatus(PlateformChannel plateformChannel) {
        plateformChannelMapper.updateByStatus(plateformChannel.getId(),plateformChannel.getStatus());
    }

    /**
     * 添加渠道
     * @param params
     */
    @Override
    @Transactional
    public void insertChannel(Map<String, Object> params) {
        log.info("【添加渠道】添加渠道insertChannel的plateformChannel={}",params.toString());
        plateformChannelMapper.inset(params);
    }
}
